<template>
  <div>
    <h1>了解学习递归--recursion</h1>
  </div>
</template>

<script setup>
for (let i = 0; i <= 10; i++) {}
// 递归代替for循序
function recursion (i) {
  i++
  //   console.log(' i++', i++)
  if (i == 10) {
    return
  }
  recursion(i)
}
recursion(0)

// 求1-100相加的和

function recursionSum (num) {
  console.log('11111111111num', num)

  if (num == 1) {
    console.log('cicccccc', num)
    debugger
    return 1
  }
  console.log('222222num', num)
  debugger

  let fn = recursionSum(num - 1)
  debugger
  console.log('33333num', num)

  console.log('fn', fn)


  let demo = fn + num
  debugger
  console.log('demo', demo)
  return demo
}
let sum = recursionSum(10)
console.log('1-100', sum)
</script>

<style lang="scss" scoped></style>
